/** $lic$
 * Copyright (C) 2012-2015 by Massachusetts Institute of Technology
 * Copyright (C) 2010-2013 by The Board of Trustees of Stanford University
 *
 * This file is part of zsim.
 *
 * zsim is free software; you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, version 2.
 *
 * If you use this software in your research, we request that you reference
 * the zsim paper ("ZSim: Fast and Accurate Microarchitectural Simulation of
 * Thousand-Core Systems", Sanchez and Kozyrakis, ISCA-40, June 2013) as the
 * source of the simulator in any publications that use this software, and that
 * you send us a citation of your work.
 *
 * zsim is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef CPUID_H_
#define CPUID_H_

/* CPUID records gathered from other machines, used to virtualize CPUID
 * CPUID is a bundle of joy. See these to get started:
 *  - http://www.sandpile.org/x86/cpuid.htm
 *  - http://www.intel.com/content/www/us/en/processors/processor-identification-cpuid-instruction-note.html
 * Try not to cry.
 */

struct CpuIdRecord {
    unsigned eaxIn;
    unsigned ecxIn;
    unsigned eax, ebx, ecx, edx;

    bool operator< (const CpuIdRecord& other) const {
        return (eaxIn < other.eaxIn) || ( (eaxIn == other.eaxIn) && (ecxIn < other.ecxIn) );
    }
};

// cpuid values produced by getcpuid (dsm)
CpuIdRecord cpuid_core2[] = { // 2-socket Xeon E5335 (2x4 cores, core2 arch, 2.00GHz)
    {0000000000, 0000000000, 0x0000000a, 0x756e6547, 0x6c65746e, 0x49656e69},
    {0x00000001, 0000000000, 0x000006f7, 0x05040800, 0x0004e33d, 0xbfebfbff},
    {0x00000002, 0000000000, 0x05b0b101, 0x005657f0, 0000000000, 0x2cb43049},
    {0x00000003, 0000000000, 0000000000, 0000000000, 0000000000, 0000000000},
    {0x00000004, 0000000000, 0x0c000121, 0x01c0003f, 0x0000003f, 0x00000001},
    {0x00000004, 0x00000001, 0x0c000122, 0x01c0003f, 0x0000003f, 0x00000001},
    {0x00000004, 0x00000002, 0x0c004143, 0x03c0003f, 0x00000fff, 0x00000001},
    {0x00000004, 0x00000003, 0000000000, 0000000000, 0000000000, 0000000000},
    {0x00000005, 0000000000, 0x00000040, 0x00000040, 0x00000003, 0x00000020},
    {0x00000006, 0000000000, 0x00000001, 0x00000002, 0x00000001, 0000000000},
    {0x00000007, 0000000000, 0000000000, 0000000000, 0000000000, 0000000000},
    {0x00000008, 0000000000, 0x00000400, 0000000000, 0000000000, 0000000000},
    {0x00000009, 0000000000, 0000000000, 0000000000, 0000000000, 0000000000},
    {0x0000000a, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000000, 0000000000, 0x80000008, 0000000000, 0000000000, 0000000000},
    {0x80000001, 0000000000, 0000000000, 0000000000, 0x00000001, 0x20100800},
    {0x80000002, 0000000000, 0x65746e49, 0x2952286c, 0x6f655820, 0x2952286e},
    {0x80000003, 0000000000, 0x55504320, 0x20202020, 0x20202020, 0x45202020},
    {0x80000004, 0000000000, 0x35333335, 0x20402020, 0x30302e32, 0x007a4847},
    {0x80000005, 0000000000, 0000000000, 0000000000, 0000000000, 0000000000},
    {0x80000006, 0000000000, 0000000000, 0000000000, 0x10008040, 0000000000},
    {0x80000007, 0000000000, 0000000000, 0000000000, 0000000000, 0000000000},
    {0x80000008, 0000000000, 0x00003024, 0000000000, 0000000000, 0000000000},
    {0x80000009, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000000a, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000000b, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000000c, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000000d, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000000e, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000000f, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000010, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000011, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000012, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000013, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000014, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000015, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000016, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000017, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000018, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x80000019, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001a, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001b, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001c, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001d, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001d, 0x00000001, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001d, 0x00000002, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001d, 0x00000003, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001d, 0x00000004, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001d, 0x00000005, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001d, 0x00000006, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0x8000001e, 0000000000, 0x07280202, 0000000000, 0000000000, 0000000000},
    {0xffffffff, 0}
};

#endif  // CPUID_H_
